//
//  VCOFSecondViewController.m
//  UI07_UINavigationController
//
//  Created by wyx on 16/3/17.
//  Copyright © 2016年 Apon. All rights reserved.
//

#import "VCOFSecondViewController.h"
#import "VCOFThirdViewController.h"

@interface VCOFSecondViewController ()
@property (nonatomic, retain) UIButton *button;
@end

@implementation VCOFSecondViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    //修改 navigationController的栈数组
    //第一页界面对象
    UIViewController *first = self.navigationController.viewControllers[0];
    //第三个界面对象
    VCOFThirdViewController *third = [[VCOFThirdViewController alloc] init];
    //第二个界面对象
    UIViewController *second = self.navigationController.topViewController;
    [self.navigationController setViewControllers:@[first,third,second] animated:NO];
    
    
    [self configNaviBar];
    [self createButton];
}
#pragma mark - 第二页隐藏 Bar
-(void)configNaviBar {
    self.navigationController.navigationBarHidden = YES;
}
#pragma mark -Button
-(void)createButton {
    self.button = [UIButton buttonWithType:UIButtonTypeSystem];
    self.button.frame = CGRectMake(50, 80, 100, 40);
    [self.button setTitle:@"Back" forState:UIControlStateNormal];
    self.button.backgroundColor = [UIColor yellowColor];
    [self.view addSubview:self.button];
    [self.button release];
    [self.button addTarget:self action:@selector(backAction:) forControlEvents:UIControlEventTouchUpInside];
}
-(void)backAction:(UIButton *)button {
    [self.navigationController popViewControllerAnimated:YES];
    self.navigationController.navigationBarHidden = NO;
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
